package com.wanmait.employment.manageController;

import com.github.pagehelper.PageInfo;
import com.wanmait.employment.entity.Userinfo;
import com.wanmait.employment.service.UserinfoService;
import com.wanmait.employment.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Create By pc on 2023/5/30.
 */
@RestController
@RequestMapping("/manage/userinfo")
public class UserInfoController {
    @Resource
    private UserinfoService userinfoService;
    @GetMapping("list")
    @ResponseBody
    public AjaxResult list(String name,int pageNum, int pageSize){
        PageInfo<Userinfo> pageInfo = userinfoService.findAll(name,pageNum, pageSize);
        return AjaxResult.success("",pageInfo);
    }
    @PostMapping("update")
    public AjaxResult update(@RequestBody Userinfo userinfo) {
       userinfoService.updata(userinfo);
       return AjaxResult.success("修改成功!");
    }
    @GetMapping("delete")
    public  AjaxResult delete(Integer id){
        userinfoService.delete(id);
        return  AjaxResult.success("删除成功!");
    }
    @GetMapping("resetpasswords")
    public  AjaxResult resetpasswords(Integer id){
        String userpass="123456";
        userinfoService.resetpasswords(id,userpass);
        return AjaxResult.success("重置成功!");
    }
    @GetMapping("resetpic")
    public AjaxResult resetpic( Integer id){
        String face="static/image/BOSS.png";
        userinfoService.resetpic(id,face);
        return AjaxResult.success("重置成功");
    }

}
